package com.jyw.business.ins.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jyw.business.ins.domain.InsPlanItem;
import com.jyw.business.ins.domain.dto.web.InsPlanItemPageDto;
import com.jyw.business.ins.domain.vo.web.InsPlanItemVO;
import com.jyw.business.ins.mapper.InsPlanItemMapper;
import com.jyw.business.ins.service.IInsPlanItemService;
import com.jyw.system.utils.ConversionUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * 巡检计划关联巡检项Service业务层处理
 *
 * @author system
 * @date 2023-10-07
 */
@Service
public class InsPlanItemServiceImpl extends ServiceImpl<InsPlanItemMapper, InsPlanItem> implements IInsPlanItemService {
    @Resource
    private InsPlanItemMapper insPlanItemMapper;

    /**
     * 查询巡检计划关联巡检项
     *
     * @param id 巡检计划关联巡检项主键
     * @return 巡检计划关联巡检项
     */
    @Override
    public InsPlanItem selectInsPlanItemById(Long id) {
        return insPlanItemMapper.selectInsPlanItemById(id);
    }

    @Override
    public List<InsPlanItemVO> pagePlanItemList(InsPlanItemPageDto insPlanItemPageDto) {
        if (insPlanItemPageDto.getBusinessId() != null && insPlanItemPageDto.getBusinessType() != null) {
            List<InsPlanItemVO> list = insPlanItemMapper.pagePlanItemList(insPlanItemPageDto);
            return ConversionUtil.conversionList(list, InsPlanItemVO.class);
        }
        return Collections.emptyList();
    }

    @Override
    public List<InsPlanItemVO> getPlanItemList(Long planId) {
        List<InsPlanItemVO> list = insPlanItemMapper.getPlanItemList(planId);
        return ConversionUtil.conversionList(list, InsPlanItemVO.class);
    }

    /**
     * 查询巡检计划关联巡检项列表
     *
     * @param insPlanItem 巡检计划关联巡检项
     * @return 巡检计划关联巡检项
     */
    @Override
    public List<InsPlanItem> selectInsPlanItemList(InsPlanItem insPlanItem) {
        return insPlanItemMapper.selectInsPlanItemList(insPlanItem);
    }


    @Override
    public int deleteByPlanId(Long planId) {
        return insPlanItemMapper.deleteByPlanId(planId);
    }

    /**
     * 批量删除巡检计划关联巡检项
     *
     * @param ids 需要删除的巡检计划关联巡检项主键
     * @return 结果
     */
    @Override
    public int deleteInsPlanItemByIds(Long[] ids) {
        return insPlanItemMapper.deleteInsPlanItemByIds(ids);
    }

    /**
     * 删除巡检计划关联巡检项信息
     *
     * @param id 巡检计划关联巡检项主键
     * @return 结果
     */
    @Override
    public int deleteInsPlanItemById(Long id) {
        return insPlanItemMapper.deleteInsPlanItemById(id);
    }
}
